#include "Comm.h"

int main()
{
    Fifo fifo(PATH);
    int fd = open(PATH, O_RDONLY);
    if (fd < 0)
    {
        cout << "open error" << endl;
        return 1;
    }
    cout << "open sucessful" << endl;
    char buffer[1024];
    while (1)
    {
        ssize_t n = read(fd, buffer, sizeof(buffer) - 1);
        if (n > 0)
        {
            buffer[n] = 0;
            cout << "client say:" << buffer << endl;
        }
        else if (n == 0)
        {
            cout << "client quit, me too" << endl;
            break;
        }
        else
        {
            cout << "read error" << endl;
            break;
        }
    }
    close(fd);

    return 0;
}